package agb.servidor;


import agb.Conexion.Conexion;
import java.sql.Connection;

import javax.naming.Context;
import javax.naming.InitialContext;
import javax.naming.NamingException;
import javax.sql.DataSource;


/**
 *
 * @author Lizardo
 */
public class ConexionBDDataSource {
    private Connection conn = null;
    private String msg = null;
    //constructor
    public ConexionBDDataSource() {
//       try {
           //conn = getPoolDatasource().getConnection();
          // ConectaLOG conectaLOG = new ConectaLOG();
           //conectaLOG.pasarConexion(conn);
        conn = Conexion.getConexion();
                
           //msg = "Conexión sastifactoria...";
//       } catch(SQLException ex) {
//           ex.printStackTrace();
//           msg = ex.getMessage();
//       } catch(SQLException ex) {
//           ex.printStackTrace();
//           msg = ex.getMessage();
//       }
    }
    
    public void setMensaje(String _msg){
        msg = _msg;
    }
    public String getMensaje() {
        return msg;
    }
    
    
    public boolean estadoConexion() {
        boolean estado = false;
        estado = (conn == null) ? false : true;
        return estado;
    }

    private DataSource getPoolDatasource() throws NamingException {
        Context c = new InitialContext();
        return (DataSource) c.lookup("java:comp/env/poolDatasource");
    }

}
